package com.xoa.service.hr.impl;

import com.xoa.dao.hr.marketingFile.HrMarketingFileMapper;
import com.xoa.service.hr.hrMarktingFile.HrMarketingFileService;
import com.xoa.util.ToJson;
import com.xoa.util.common.StringUtils;
import com.xoa.util.page.PageParams;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by liuqian on 2019/4/2.
 */
@Service
public class HrMarketingFileServiceImpl implements HrMarketingFileService {

    @Resource
    HrMarketingFileMapper hrMarketingFileMapper;
    @Override
    public ToJson queryDataEmpsYx(HttpServletRequest request,String dataSrc, String dataField, String dataQuery,
                                  Integer page, Integer pageSize, Boolean useFlag) {

        ToJson dataEmpsYxToJson = new ToJson<>();
        return dataEmpsYxToJson;
      /*  PageParams pageParams=new PageParams();
        pageParams.setPage(page);
        pageParams.setPageSize(pageSize);
        pageParams.setUseFlag(useFlag);
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("page",pageParams);
        map.put("dataSrc",dataSrc);//数据库表名
        String[] dataQueryArray = null;
        if(!StringUtils.checkNull(dataQuery)){
            dataQueryArray = dataQuery.split(",");
        }
        String[] dataFieldStr = null;
        if(!StringUtils.checkNull(dataField)){
            dataFieldStr = dataField.split(",");
        }
        map.put("dataField",dataField);//要查询的属性返回值
        String[] dataQueryStr = null;
        if(!StringUtils.checkNull(dataField)){
            dataQueryStr = dataQuery.split(",");
        }
        String string="";
        map.put("dataQueryStr",dataQueryStr);
        int i =0;
        for(int j=0;j<dataQueryStr.length;j++){
            if("1".equals(dataQueryStr[j])){
                  String str = request.getParameter(dataFieldStr[j]);
                  string +=" "+ dataFieldStr[j]+ " like '%"+  str +"%' and";
                i = i+1;
            }
        }
        //如果有搜索条件去除最后and
        if(i>0){
            string = string.substring(0,string.length()-3);
        }
         map.put("string",string);
        List <Map<String,Object>>dataEmpsYxes = hrMarketingFileMapper.queryDataEmpsYx(map);
        if(dataEmpsYxes.size()>0){
            dataEmpsYxToJson.setFlag(0);
            dataEmpsYxToJson.setTotleNum(pageParams.getTotal());
        }
        dataEmpsYxToJson.setObject(dataEmpsYxes);
        return dataEmpsYxToJson;*/
    }
}
